<template>
  <a-spin :spinning="confirmLoading">
    <j-form-container :disabled="formDisabled">
      <a-form-model ref="form" :model="model" :rules="validatorRules" slot="detail">
        <a-row>
          <a-col :span="12">
            <a-form-model-item label="数据日期" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="dataDt">
              <j-date placeholder="请输入数据日期" v-model="model.dataDt"  style="width: 100%" />
            </a-form-model-item>
          </a-col>
          <a-col :span="12">
            <a-form-model-item label="金融机构代码" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="jrjgdm">
              <a-input v-model="model.jrjgdm" placeholder="请输入金融机构代码"  ></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="12">
            <a-form-model-item label="内部机构号" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="nbjgh">
              <a-input v-model="model.nbjgh" placeholder="请输入内部机构号"  ></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="12">
            <a-form-model-item label="客户证件类型" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="khzjlx">
              <a-input v-model="model.khzjlx" placeholder="请输入客户证件类型"  ></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="12">
            <a-form-model-item label="客户证件代码" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="khzjdm">
              <a-input v-model="model.khzjdm" placeholder="请输入客户证件代码"  ></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="12">
            <a-form-model-item label="注册地址" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="zcdz">
              <a-input v-model="model.zcdz" placeholder="请输入注册地址"  ></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="12">
            <a-form-model-item label="客户地区代码" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="khdqdm">
              <a-input v-model="model.khdqdm" placeholder="请输入客户地区代码"  ></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="12">
            <a-form-model-item label="存款账户编码" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="ckzhbm">
              <a-input v-model="model.ckzhbm" placeholder="请输入存款账户编码"  ></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="12">
            <a-form-model-item label="存款协议代码" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="ckxydm">
              <a-input v-model="model.ckxydm" placeholder="请输入存款协议代码"  ></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="12">
            <a-form-model-item label="存款产品类别" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="ckcplb">
              <a-input v-model="model.ckcplb" placeholder="请输入存款产品类别"  ></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="12">
            <a-form-model-item label="存款协议起始日期" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="ckxyqsrq">
              <j-date placeholder="请选择存款协议起始日期" v-model="model.ckxyqsrq"  style="width: 100%" />
            </a-form-model-item>
          </a-col>
          <a-col :span="12">
            <a-form-model-item label="存款协议到期日期" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="ckxydqrq">
              <j-date placeholder="请选择存款协议到期日期" v-model="model.ckxydqrq"  style="width: 100%" />
            </a-form-model-item>
          </a-col>
          <a-col :span="12">
            <a-form-model-item label="币种" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="bz">
              <a-input v-model="model.bz" placeholder="请输入币种"  ></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="12">
            <a-form-model-item label="存款余额" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="ckye">
              <a-input-number v-model="model.ckye" placeholder="请输入存款余额" style="width: 100%" />
            </a-form-model-item>
          </a-col>
          <a-col :span="12">
            <a-form-model-item label="存款余额折人民币" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="ckyezrmb">
              <a-input-number v-model="model.ckyezrmb" placeholder="请输入存款余额折人民币" style="width: 100%" />
            </a-form-model-item>
          </a-col>
          <a-col :span="12">
            <a-form-model-item label="利率水平" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="llsp">
              <a-input-number v-model="model.llsp" placeholder="请输入利率水平" style="width: 100%" />
            </a-form-model-item>
          </a-col>
          <a-col :span="12">
            <a-form-model-item label="缴存准备金方式" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="jczbjfs">
              <a-input v-model="model.jczbjfs" placeholder="请输入缴存准备金方式"  ></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="12">
            <a-form-model-item label="科目代码" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="subjectNo">
              <a-input v-model="model.subjectNo" placeholder="请输入科目代码"  ></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="12">
            <a-form-model-item label="科目名称" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="subjectName">
              <a-input v-model="model.subjectName" placeholder="请输入科目名称"  ></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="12">
            <a-form-model-item label="客户名称" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="khmc">
              <a-input v-model="model.khmc" placeholder="请输入客户名称"  ></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="12">
            <a-form-model-item label="客户代码" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="khdm">
              <a-input v-model="model.khdm" placeholder="请输入客户代码"  ></a-input>
            </a-form-model-item>
          </a-col>
        </a-row>
      </a-form-model>
    </j-form-container>
  </a-spin>
</template>

<script>

  import { httpAction, getAction } from '@/api/manage'
  import { validateDuplicateValue } from '@/utils/util'

  export default {
    name: 'JsPExNobankUnitDepositForm',
    components: {
    },
    props: {
      //表单禁用
      disabled: {
        type: Boolean,
        default: false,
        required: false
      }
    },
    data () {
      return {
        model:{
         },
        labelCol: {
          xs: { span: 24 },
          sm: { span: 5 },
        },
        wrapperCol: {
          xs: { span: 24 },
          sm: { span: 16 },
        },
        confirmLoading: false,
        validatorRules: {
        },
        url: {
          add: "/jsPExNobankUnitDeposit/jsPExNobankUnitDeposit/add",
          edit: "/jsPExNobankUnitDeposit/jsPExNobankUnitDeposit/edit",
          queryById: "/jsPExNobankUnitDeposit/jsPExNobankUnitDeposit/queryById"
        }
      }
    },
    computed: {
      formDisabled(){
        return this.disabled
      },
    },
    created () {
       //备份model原始值
      this.modelDefault = JSON.parse(JSON.stringify(this.model));
    },
    methods: {
      add () {
        this.edit(this.modelDefault);
      },
      edit (record) {
        this.model = Object.assign({}, record);
        this.visible = true;
      },
      submitForm () {
        const that = this;
        // 触发表单验证
        this.$refs.form.validate(valid => {
          if (valid) {
            that.confirmLoading = true;
            let httpurl = '';
            let method = '';
            if(!this.model.id){
              httpurl+=this.url.add;
              method = 'post';
            }else{
              httpurl+=this.url.edit;
               method = 'put';
            }
            httpAction(httpurl,this.model,method).then((res)=>{
              if(res.success){
                that.$message.success(res.message);
                that.$emit('ok');
              }else{
                that.$message.warning(res.message);
              }
            }).finally(() => {
              that.confirmLoading = false;
            })
          }

        })
      },
    }
  }
</script>
